<template>
	<view class="login">
		<image src="" v-model="imgg"></image>
		<view class="main">
			<uni-easyinput class="main-list " v-model="username" placeholder="请输入账号"></uni-easyinput>
			<uni-easyinput class="main-list " type="password" v-model="password" placeholder="请输入密码"></uni-easyinput>
		</view>
		<button style="width: 50%;" @click="logLin" >登录</button>
		<navigator  url="./sign/sign" class="zc" >注册账号</navigator>
	</view>
</template>

<script>
	import { doLogin } from"@/api/user/login/index.js"
	export default {
		data() {
			return {
				imgg:"../../../static/icons/alipay.png",
				// username:"17596496508",  
				username:"15238799514",
				password:"123456",
			};
			
			
			
		},
		
		methods:{
		// 登录
			init(){
				doLogin({
					  password: this.password,
					  username: this.username,
					 
				}).then(res=>{
					console.log(res) ;
					// 存到本地
					if(res.success){
						uni.setStorageSync("toten",res.data.token)
						//弹出对话框
						uni.showToast({
							title:"登录成功",
							// url:"../user"
						}),
						// 定时器
						setTimeout(()=>{
							uni.switchTab({
								url:"../user"
							})
						},1000)
					}
					
				})
			},
			logLin(){
				this.init(),
				console.log("登录了");
			}
		}
	}
</script>

<style lang="scss" scoped>
	.login{
		.zc{
			// width: 20%;
			text-align: center;
			margin: 0 auto;
			margin-top: 20rpx;
		}
		image{
		
			background-color: #007AFF;
			display: block;
			width: 160rpx;
			height: 160rpx;
			border-radius: 50rem;
			margin: 0 auto;
			margin-top: 60rpx;
		}
		.main{
			width: 80%;
			margin-left: 80rpx;
			margin-top: 140rpx;
			.main-list{
				margin: 40rpx;
				width: 80%;
			}
		}
	}

</style>
